package com.yixin.vuehr.util;

import cn.hutool.core.util.StrUtil;
import com.yixin.vuehr.mapper.OpLogMapper;
import com.yixin.vuehr.model.OpLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.Date;

@Component
public class OpreateUtil {
    private static String MESSAGE = "做了点操作。。。";
    @Autowired
    OpLogMapper opLogMapper;

    private static OpreateUtil opreateUtil;
    @PostConstruct
    public void init(){
        opreateUtil = this;
        opreateUtil.opLogMapper = this.opLogMapper;
    }

    public static void addOp(String msg){
        if (StrUtil.isEmpty(msg)){
            msg = MESSAGE;
        }
        OpLog log = new OpLog(HrUtils.getCurrentHr().getId(),msg,new Date());
        opreateUtil.opLogMapper.insertSelective(log);
    }
    public static void addOp(Integer hrId,String msg){
        if (StrUtil.isEmpty(msg)){
            msg = MESSAGE;
        }
        OpLog log = new OpLog(hrId,msg,new Date());
        opreateUtil.opLogMapper.insertSelective(log);
    }


}
